<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>门店管理</title>
    <#include "/common/link.ftl">

    <script>
        $(function () {
            $('.input-date').datepicker({
                format:'yyyy-mm-dd', //格式
                language:'zh-CN', //中文
                autoclose: true,//选择后自动关闭
                //showMeridian:true, //是否显示上下午
                minView:2,//精确到哪位
            });
        });
    </script>

</head>
<body class="hold-transition skin-black sidebar-mini">
<div class="wrapper">
    <#include "/common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu="business"/>
    <#include "/common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>门店管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <div style="margin: 20px 0px 0px 10px">
                    <form class="form-inline" id="searchForm" action="/business/list" method="post">
                        <input type="hidden" name="currentPage" id="currentPage" value="1">
                                <div class="form-group">
                                    <label for="name">门店名称：</label>
                                    <input type="text" class="form-control" name="name" value="${qo.name}"
                                           placeholder="请输入门店名称">
                                </div>
                                <div class="form-group">
                                    <label for="scope">经营范围：</label>
                                    <input type="text" class="form-control" name="scope" value="${qo.scope}"
                                           placeholder="请输入经营范围">
                                </div>
                                <div class="form-group">
                                    <label for="tel">门店联系方式：</label>
                                    <input type="text" class="form-control" name="tel" value="${qo.tel}"
                                           placeholder="请输入门店联系方式">
                                </div>
                                <div class="form-group">
                                    <label for="legalName">根据法人查询：</label>
                                    <input type="text" class="form-control" name="legalName" value="${qo.legalName}"
                                           placeholder="请输入法人姓名">
                                </div>

                                <br/>
                                <br/>
                                <div class="form-group">
                                    <label>经营日期查询：</label>
                                    <input placeholder="请输入开始日期" type="text" class="form-control input-date" name="beginDate"
                                      value="${((qo.beginDate)?string('yyyy-MM-dd'))!}"/> -
                                    <input placeholder="请输入结束日期" type="text" class="form-control input-date" name="endDate"
                                           value="${((qo.endDate)?string('yyyy-MM-dd'))!}"/>
                                </div>

                                <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span> 查询</button>

                                <a href="/business/input" class="btn btn-success">
                                    <span class="glyphicon glyphicon-plus"></span> 添加
                                </a>
                    </form>

                </div>
                <div class="box-body table-responsive">
                <table class="table table-hover table-bordered table-striped">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>门店名称</th>
                        <th>门店电话</th>
                        <th>门店地址</th>
                        <th>经营时间</th>
                        <th>门店性质</th>
                        <th>门店详情</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <#list pageInfo.list as business>
                        <tr>
                            <td>${business_index+1}</td>
                            <td>${business.name!}</td>
                            <td>${business.tel!}</td>
                            <td>${business.address!}</td>
                            <td>${(business.openDate)?string('yyyy-MM-dd')!}</td>
                            <td>${(business.mainStore==1)?string('总店','分店')!}</td>
                            <#--<td>${business.storeDisplay!}
                            </td>-->
                            <td>
                                <a href="#" class="btn btn-info btn-xs btn-input" data-json='${business.toJson()}'>
                                    <span class="glyphicon glyphicon-pencil"></span> 门店详情
                                </a>
                            </td>
                            <td>
                                <a href="/business/input?id=${business.id}" class="btn btn-info btn-xs">
                                    <span class="glyphicon glyphicon-pencil"></span> 编辑
                                </a>
                            </td>
                        </tr>
                    </#list>
                    </tbody>
                </table>
                <#include "/common/page.ftl">
                </div>
            </div>
        </section>
    </div>
    <#include "/common/footer.ftl">
</div>

<!-- 模态框-->

<div class="modal fade" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close"  id="buttondetail" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">门店详情</h4>
            </div>

            <form action="#" method="post" id="detailFrom">
                <input type="hidden" name="id">
                <div class="modal-body">
                    <div class="form-group">
                        <label for="name">门店名称</label>
                        <input type="text" class="form-control" id="name" disabled name="name" >
                    </div>
                    <div class="form-group">
                        <label for="sn">门店电话</label>
                        <input type="text" class="form-control" id="tel" disabled name="tel" >
                    </div>
                    <div class="form-group">
                        <label for="sn">门店地址</label>
                        <input type="text" class="form-control" id="address" disabled name="address" >
                    </div>
                    <#--<div class="form-group">
                        <label for="sn">门店介绍</label>
                        <input type="text" class="form-control" id="intro" name="intro" >
                    </div>-->
                    <div class="form-group">
                        <label for="sn">门店介绍</label>
                        <textarea disabled name="intro">

                        </textarea>
                    </div>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">返回</button>
                </div>
            </form>
        </div>
    </div>
</div>


<script>
    $(function () {
        $('.btn-input').click(function () {
            //获取被点击的按钮
            var $btn=$(this);
            var data=$btn.data('json');

            //清除模态框之前显示的数据
            $('#detailFrom').clearForm(true);
            if (data){ //编辑的时候回显数据
                $('#detailFrom input[name=id]').val(data.id);
                $('#detailFrom input[name=name]').val(data.name);
                $('#detailFrom input[name=tel]').val(data.tel);
                $('#detailFrom input[name=address]').val(data.address);
                $('#detailFrom input[name=intro]').val(data.intro);
                $('#detailFrom textarea[name=intro]').val(data.intro);
                //$('input[name=mainStore]').val(data.mainStore);
            }
            /*console.log(data.id);
            console.log(data.name);
            console.log(data.sn);*/

            $('.modal').modal('show')
        });

    });
</script>

</body>
</html>
